Imports System.Data.SqlClient
Imports System.IO
Public Class Conexion
    Protected cnn As SqlConnection
    Dim servidor As String
    Dim Leer As New StreamReader("C:\LexPreceptor\cnn.txt")
    Protected Function conectar()
        Try
            servidor = Leer.ReadLine()
            cnn = New SqlConnection("Data Source=" & servidor & ";Initial Catalog=Juridico;Integrated Security=True")
            cnn.Open()
            Return True
        Catch ex As Exception
            MsgBox(ex.Message)
            Return False
        End Try
    End Function

    Protected Function desconectar()
        Try
            If cnn.State = ConnectionState.Open Then
                cnn.Close()
                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
            Return False
        End Try
    End Function
End Class
